<%-- 
    Document   : picker
    Created on : 25.11.2012, 19:13:16
    Author     : Lukas Marica
--%>

<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<s:useActionBean beanclass="cz.muni.fi.pa165.web.SecurityActionBean" var="securityBean"/>
<f:message key="title.pickerlist" var="headline" />
<s:layout-render name="/layout.jsp" headline="${headline}">
	<s:layout-component name="content">
		<s:useActionBean beanclass="cz.muni.fi.pa165.web.PickerActionBean" var="actionBean"/>

		<table class="listtable">
			<tr>
                                <th width="20%"><f:message key="picker.login"/></th>
				<th width="19%"><f:message key="picker.name"/></th>
				<th width="19%"><f:message key="picker.surname"/></th>
				<th width="20%"><f:message key="picker.info"/></th>
				<th width="12%"><f:message key="picker.isAdmin"/></th>
				<th width="5%"></th>
				<th width="5%"></th>
			</tr>
			<c:forEach items="${actionBean.pickers}" var="picker" varStatus="status">
				<tr class="${(status.count % 2 == 0 ) ? "even" : "odd"}">
                                        <td><c:out value="${picker.login}"/></td>
					<td><c:out value="${picker.name}"/></td>
					<td><c:out value="${picker.surname}"/></td>
					<td><c:out value="${picker.info}"/></td>
					<td><c:out value="${picker.isAdmin}"/></td>
					<td><c:if test="${securityBean.isAdminLoggedIn or securityBean.currentUserID eq picker.id}"><s:link beanclass="cz.muni.fi.pa165.web.PickerActionBean" event="edit"><s:param name="picker.id" value="${picker.id}"/><f:message key="edit"/></s:link></c:if> </td>
					<td><c:if test="${securityBean.isAdminLoggedIn}"><s:link addSourcePage="true" beanclass="cz.muni.fi.pa165.web.PickerActionBean" event="delete" class="deleteentity" title="${picker.name} ${picker.surname}"><s:param name="picker.id" value="${picker.id}"/><f:message key="delete"/></s:link></c:if> </td>
					</tr>
			</c:forEach>
		</table>
				<c:if test="${securityBean.isAdminLoggedIn}">
		<s:form beanclass="cz.muni.fi.pa165.web.PickerActionBean">
			<fieldset><legend><f:message key="new"/></legend>
				<%@include file="pickerform.jsp"%>
				<s:submit name="add"><f:message key="create"/></s:submit>
				</fieldset>
		</s:form>
				</c:if>
	</s:layout-component>
</s:layout-render>
